<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>小程序</title>
</head>
<body>
    
</body>
<!-- 小程序发送数据给后台 -->
<script type="text/javascript">
    wx.request({
      url: url + '/Orderindex/index', //地址
      data: {
        page: 1  //要发送的数据
      },
      header: {
        'content-type': 'application/json'
      },
      method: 'GET',
      success: function (res) {
        that.setData({ 
          ts: res.data.data,  //返回的值,直接模板遍历输出至页面
          page_all: res.data.page  //页面模板样式  wx:for="{{ts}}" wx:for-index="idx" wx:for-item='itemName'
          });
      },visi_one
    })
</script>
<!-- 上拉加载更多 -->
<script type="text/javascript">
onReachBottom: function () {
    var that = this
    var page_all = that.data.page_all  //拿取后台返回的数据
    if (page<=page_all) {
      wx.showToast({
        title: '加载中',  //出现加载中图标
        icon: 'loading',
        duration: 1000
      })
      wx.request({
        url: url + '/Orderindex/index', //上拉加载发送的接口
        data: {
          page: page   //发送的数据
        },
        header: {
          'content-type': 'application/json'
        },
        method: 'GET',
        success: function (res) {  //后台返回的数据
          that.setData({
            ts: that.data.ts.concat(res.data.data),  //concat拼接,将数据拼接到原数据之后
            page: page
          });
          page++;
        }
      })
    } 
},
</script>
<!-- 点击跳转事件 -->
<script type="text/javascript">
toast: function (evel) {
    var idd = evel.currentTarget.id;
    wx.navigateTo({
      url: '../audio/audio?id='+idd   //跳转的地址,页面中绑定bindtap="toast"
    })
}
</script>
<!-- 遍历数据 -->
<!-- html -->
<view class='view_1' wx:for="{{ts}}" wx:for-index="idx" wx:for-item='itemName'  >
    <image src='http://{{itemName.img}}' bindtap="toast" id="{{itemName.id}}"  class='index_img'></image>
    <view class='index_text first'>
      <text style='color:#877A68;font-size:15px;'>{{itemName.title}}</text>
    </view>
    <view class='index_text'>
      <text style="color:#CECECE;font-size:12px;">{{itemName.brief}}</text>
    </view>
</view>
<!-- js -->
<script type="text/javascript">
     wx.showToast({
      title: '加载中',
      icon: 'loading',
      duration: 500
    }),
    wx.request({
      url: url + '/Orderindex/index',
      data: {
        page: 1
      },
      header: {
        'content-type': 'application/json'
      },
      method: 'GET',
      success: function (res) {
        that.setData({ 
          ts: res.data.data,
          page_all: res.data.page
          });
      },
    })
</script>
</html>